/*******************************************************************************
 *
 *      Filename: Timer.h
 *   Description: 
 *        Author: [kb]ypp
 *    Created at: November 28, 2005
 * Last modified: November 30, 2005
 *
 ******************************************************************************/

#ifndef TIMER_H
#define TIMER_H

//! @brief Class for stopwatch-like timer
//!
//! The time measured in milliseconds. Has platform-specific implementation
class Timer {
public:
	//! @brief Default constructor
	Timer();
	//! @brief Copy-constructor
	Timer( const Timer &other );
	//! @brief Assignment operator
	const Timer& operator=( const Timer &other );
	//! @brief Destructor
	~Timer();
	
	//! @brief Start the timer
	void start();
	//! @brief Stop the timer
	void stop();
	//! @brief Reset the timer
	void reset();
	
	//! @brief Time elapsed from timer start (in seconds)
	float elapsed() const;
	//! @brief Time elapsed from the last call to delta()
	float delta() const;
	
private:
	//! @brief Update sec
	void update() const;
	
	mutable float sec;  //!< Seconds elapsed from the timer start
	mutable float last; //!< Seconds elapsed when was the last delta() call
	bool running;      //!< Is the timer running? (as opposed to stopped)
	
	class TimerImpl;
	TimerImpl *impl;    //!< Platform-dependent timer state data
};

#endif // TIMER_H
